package com.hopu.shop.dao.imp;

import com.hopu.shop.dao.SupportDao;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

//持久层连接数据库
@Repository("supportDao")
public class SupportDaoImp implements SupportDao {


    @Resource(name="sqlSessionTemplate")
    SqlSessionTemplate sqlSessionTemplate;


    /**
     * 查询
     * @param map
     * @return
     * @throws Exception
     */
    @Override
    public List<?> query(String str,Map map) throws Exception {
        return sqlSessionTemplate.selectList(str,map);
    }


    /**
     * 修改
     * @param str
     * @param map
     * @return
     * @throws Exception
     */
    @Override
    public int upd(String str, Map map) throws Exception {
        return sqlSessionTemplate.update(str,map);
    }


    /**
     * 新增
     * @param str
     * @param map
     * @return
     * @throws Exception
     */
    @Override
    public int sava(String str, Map map) throws Exception {

        return sqlSessionTemplate.insert(str,map);
    }


    /**
     * 删除
     * @param str
     * @param map
     * @return
     * @throws Exception
     */
    @Override
    public int del(String str, Map map) throws Exception {
        return sqlSessionTemplate.delete(str,map);
    }



    @Override
    public Map inofcount(String str, Map map) throws Exception {
        return sqlSessionTemplate.selectOne(str,map);
    }
}
